//
//  TransferView.m
//  iMoney
//
//  Created by Sean on 3/31/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "TransferView.h"
#import "iMoneyAppDelegate.h"

@implementation TransferView

- (IBAction) closeTransfer:(UIButton*) sender
{
	[self removeFromSuperview];
	[((iMoneyAppDelegate*)[[UIApplication sharedApplication] delegate]) toggleTabBar];
	[((iMoneyAppDelegate*)[[UIApplication sharedApplication] delegate]) toggleNavBar];
}


- (id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
		
		UIImageView* background = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"gradientBackground.png"]];
		[self addSubview:background];
		[self sendSubviewToBack:background];
		[background release];
		
		
		toTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height-90) style: UITableViewStylePlain];
		
		//self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
		toTable.separatorStyle = UITableViewCellSeparatorStyleNone;
		toTable.rowHeight = 60;
		toTable.backgroundColor = [UIColor clearColor];
		
		toTable.dataSource = self;
		toTable.delegate = self;
		
		toTable.autoresizesSubviews= YES;
		
		
		
		UIButton *done = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
		done.frame = CGRectMake(10, 10, 100, 30);
		[done setTitle:@"Done" forState:UIControlStateNormal];
		done.backgroundColor = [UIColor clearColor];
		[done setTitleColor:[UIColor grayColor] forState:UIControlStateNormal ];
		[done addTarget:self action:@selector(closeTransfer:) forControlEvents:UIControlEventTouchUpInside];
	
		[self addSubview:toTable];
		[self addSubview:done];
		
		
		
    }
    return self;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}


// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
	
	return [[iMoneyAppDelegate getMoneyState] numAccounts]-1;
}


// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    
	//diable highlighting
	cell.selectionStyle = UITableViewCellSelectionStyleNone;
	cell.accessoryType = UITableViewCellAccessoryNone;
	
	[cell setBackgroundColor:[UIColor colorWithRed:211.0/255.0 green:211.0/255.0 blue:211.0/255.0 alpha:1.0]];
	
	cell.textLabel.textColor = [UIColor blackColor];
	
	
	
	
    return cell;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
	//DO nothing
}


- (void)drawRect:(CGRect)rect {
    // Drawing code
}


- (void)dealloc {
	//[toTable release];
	//[fromTable release];
    [super dealloc];
}


@end
